const express = require('express');


const detailPageRouter = express.Router()

const getGoodsAllData = require('../models/js/getGoodsAllData')


//详情页面 
detailPageRouter.get('/productDetail/detail', function(req, res) {
    var goodsId = req.query.id
    console.log(goodsId);
    getGoodsAllData.getGoodsAllData(function(response) {
            // for (var j = 0; j < response.length; j++) {
            // console.log(response.length);     
            // var category = response[j].title
            response.forEach((ele) => {
                    if (goodsId == ele.id) {
                        // console.log(ele);
                        // console.log(ele.price); 

                        res.render('goods.html', ele)
                    }
                })
                // }

        })
        // console.log(goodsId);
})
module.exports = detailPageRouter